$(function(){
   $.ajax({
        type: "get",
        url: "http://chst.vip:1234/api/getbaicaijiatitle?pageid=1"
    }).then((res) => {
        var arr = res.result;
        let html = ''
        arr.forEach(item =>{
             html += 
             `
             <li date-titleId=${item.titleId}>${item.title}</li>
            
             `
        })
        $('.select').html(html)

        $(".select").on("click", "li", function () {
            let productid = $(this).attr("date-titleId")
            $.ajax({
                type: "get",
                url: `http://chst.vip:1234/api/getbaicaijiaproduct?titleid=${productid}`
            }).then((res) => {
                var arr = res.result;
                let html = ''
                arr.forEach(item =>{
                     html += 
                     `
                     <li>
                        <a href="" class="clearfix">
                          <div class="img">${item.productImg}</div>
                          <div class="infoR">
                              <div class="title">
                                  <h4>${item.productName}</h4>
                                  <div class="price">${item.productPrice}</div>
                              </div>
                              <div class="down">
                                  <div class="bar">
                                    <div class="bar_in" style="width: 118px;">100%</div>
                                  </div>
                                  <span class="yiling">已领126张/剩余0张</span>
                                  <div class="click">
                                      <div class="left">点此领取优惠卷</div>
                                      <div class="right">下单链接</div>
                                  </div>
                              </div>
                          </div>
                        </a>
                    </li>
                    
                     `
                })
                $('.info').html(html) 
            })
        })

    })
    $.ajax({
        type: "get",
        url: `http://chst.vip:1234/api/getbaicaijiaproduct?titleid=0`
    }).then((res) => {
        var arr = res.result;
        let html = ''
        arr.forEach(item =>{
             html += 
             `
             <li>
                <a href="" class="clearfix">
                  <div class="img">${item.productImg}</div>
                  <div class="infoR">
                      <div class="title">
                          <h4>${item.productName}</h4>
                          <div class="price">${item.productPrice}</div>
                      </div>
                      <div class="down">
                          <div class="bar">
                            <div class="bar_in" style="width: 118px;">100%</div>
                          </div>
                          <span class="yiling">已领126张/剩余0张</span>
                          <div class="click">
                              <div class="left">点此领取优惠卷</div>
                              <div class="right">下单链接</div>
                          </div>
                      </div>
                  </div>
                </a>
            </li>
            
             `
        })
        $('.info').html(html) 
    })
}) 


 